//
//  BoarSuperCollCell.swift
//  ANOA
//
//  Created by 邱仙凯 on 2022/11/2.
//  Copyright © 2025 aowang. All rights reserved.
//

import UIKit
 
class BoarSuperCollCell: UICollectionViewCell {
    
    var img: UIImageView = {
        let img = UIImageView()
        return img
    }()
    
    private var title: UILabel = {
        let lab :UILabel = UILabel()
        lab.textColor = UIColor(kshex: "#8991B0")
        lab.font = UIFont.boldSystemFont(ofSize: 12)
        lab.numberOfLines = 2
        lab.textAlignment = .center
        return lab
    }()
    
    //  ▲  ▴ ▾
    var hasSubTriangle: UIImageView = {
        let v = UIImageView()
        v.image = UIImage(named: "down_tri")
        v.isHidden = true
        return v
    }()
    
    func setTitle(_ str:String) {
        title.text = str
    }
    
    convenience required init(coder : NSCoder){
        self.init()
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initUtil()
    }
    
    func initUtil() {
        self.backgroundColor = Theme.pureWhite()

        self.addSubview(img)
        img.snp.makeConstraints { (make) in
            make.centerX.equalTo(self)
            if PlatformManager.shared.platform == .zhuYouAn {
                make.top.equalToSuperview().offset(10)
            } else {
                make.bottom.equalTo(self.snp.centerY).offset(0)
            }
            make.width.equalTo(self).multipliedBy(0.38)
            make.height.equalTo(img.snp.width)
        }
        
        self.addSubview(title)
        title.snp.makeConstraints { (make) in
            make.centerX.equalTo(self)
            make.top.equalTo(img.snp.bottom).offset(3)
            make.left.right.equalTo(self)
        }
        
        self.addSubview(hasSubTriangle)
        hasSubTriangle.snp.makeConstraints { (make) in
            if PlatformManager.shared.platform == .zhuYouAn {
                make.top.equalTo(img).offset(1)
                make.left.equalTo(img.snp.right).offset(4)
            } else {
                make.top.equalTo(self).offset(1)
                make.right.equalTo(self).offset(-6)
            }
            make.width.equalTo(10)
            make.height.equalTo(10)
        }
    }
}
